import Vue from 'vue'
import Vuex from 'vuex'
import {state,getters} from './state'
import mutations_type from './mutations_type';
// import {getDataItem} from './../apis/api_system.js';

Vue.use(Vuex)

export default new Vuex.Store({
  getters:getters,
  state: state,
  mutations: {
    [mutations_type.UPDATA_userdata](state,info){
      console.log(info);
      let menu_data = Vue.local.get("menu_list");
      console.log(menu_data);
      this.commit(mutations_type.UPDATA_menu_list,menu_data)
      this.dispatch('getDataItem');
      state.userdata = info;
    },
    [mutations_type.UPDATA_dataitem](state,info){
      state.dataItem = info;
    },
    [mutations_type.UPDATA_menu_list](state,info){
      state.menu_list = info;
    }
  },
  actions: {
    // 通用字段查询
    getDataItem({commit}){
      getDataItem({}).then((result) => {
          if (result.code == 0) {
              commit(mutations_type.UPDATA_dataitem,result.data);
          };
      });
    }
  }
});
